[SUBROUTINE]
version = 1.14
icon = probe-grid.png
name = _("Probe Grid")
type = probe-array
help = _("<b>Probe Array of Points on stock and save to a file</b>")
order = act h1 fn depth rev dx dy dir

[PARAM_ACT]
name = _("Active")
icon = enable.png
type = bool
value = 1

[PARAM_FN]
name = _("File name")
icon = file-probe.png
type = string
tool_tip = _("Enter file name to save to")
value = probe-results.txt
header = h1

[PARAM_H1]
name = _("Probing and offsets")
type = sub-header

[PARAM_DX]
name = _("dX")
type = float
icon = dx.png
tool_tip = _("X offset")
value = 0.25
metric_value = 6
minimum_value = 0.0
header = h1

[PARAM_DY]
name = _("dY")
type = float
icon = dy.png
tool_tip = _("Y offset")
value = 0.25
metric_value = 6
minimum_value = 0.0
header = h1

[PARAM_DIR]
name = _("Master")
type = combo
icon = xy-axes.png
tool_tip = _("Master axis to follow")
value = 0
options = _("X axis=0:Y axis=1")
header = h1

[PARAM_DEPTH]
name = _("Depth")
type = float
icon = probe-down.png
tool_tip = _("Maximum depth")
value = -0.3
metric_value = -5
header = h1

[PARAM_REV]
name = _("Reverse latch dir")
type = bool
icon = change-dir.png
value = 0
header = h1

[CALL]
content =
	(begin #sub_name)
	(probe array author : Fernand Veilleux)
	
	o<#self_id_active> if [#param_act]
		o<#self_id_rev0> if [#param_rev]
			#<_probe_latch> = -#<_probe_latch>
		o<#self_id_rev0> endif
		
		(probeopen,#param_fn)
		o<#self_id_ax> if [#param_dir]
			#<probe_Y> = [#<wp_front> + #param_dy / 2]
			o<#self_id_Y_loop> while [#<probe_Y> LT #<wp_rear>]
				#<probe_X> = [#<wp_left> + #param_dx / 2]
				o<#self_id_X_loop> while [#<probe_X> LT #<wp_right>]
					G0 Z[#<_rapid_z>]
					G0 X#<probe_X> Y#<probe_Y>
;					G0 Z[#<surface> + #<_rapid_z>]
					o<probe> call [0] [0] [#param_depth]
					#<probe_X> = [#<probe_X> + #param_dx]
				o<#self_id_X_loop> endwhile
				#<probe_Y> = [#<probe_Y> + #param_dy]
			o<#self_id_Y_loop> endwhile
			
		o<#self_id_ax> else
			#<probe_X> = [#<wp_left> + #param_dx / 2]
			o<#self_id_X_loop1> while [#<probe_X> LT #<wp_right>]
				#<probe_Y> = [#<wp_front> + #param_dy / 2]
				o<#self_id_Y_loop1> while [#<probe_Y> LT #<wp_rear>]
					G0 Z[#<_rapid_z>]
					G0 X#<probe_X> Y#<probe_Y>
;					G0 Z[#<surface> + #<_rapid_z>]
					o<probe> call [0] [0] [#param_depth]
					#<probe_Y> = [#<probe_Y> + #param_dy]
				o<#self_id_Y_loop1> endwhile
				#<probe_X> = [#<probe_X> + #param_dx]
			o<#self_id_X_loop1> endwhile
		o<#self_id_ax> endif
		(probeclose)
		G0 Z[#<_rapid_z>]
		
		o<#self_id_rev1> if [#param_rev]
			#<_probe_latch> = -#<_probe_latch>
		o<#self_id_rev1> endif
		
	o<#self_id_active> endif
	(end #sub_name)
